<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>LibCDS: /home/zsshen/Desktop/git-hub-code/C-Common-Data-Structures/include/container/vector.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">LibCDS
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('vector_8h.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">vector.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>The dynamically growable array.  
<a href="#details">More...</a></p>

<p><a href="vector_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structVector.html">Vector</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">The implementation for dynamically growable array.  <a href="structVector.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ae7e1bc0ebd3e2d9616179a88c660aafe"><td class="memItemLeft" align="right" valign="top">typedef struct _VectorData&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#ae7e1bc0ebd3e2d9616179a88c660aafe">VectorData</a></td></tr>
<tr class="memdesc:ae7e1bc0ebd3e2d9616179a88c660aafe"><td class="mdescLeft">&#160;</td><td class="mdescRight">VectorData is the data type for the container private information.  <a href="#ae7e1bc0ebd3e2d9616179a88c660aafe">More...</a><br/></td></tr>
<tr class="separator:ae7e1bc0ebd3e2d9616179a88c660aafe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aee13af756ae9331b7cffd5915608d988"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#aee13af756ae9331b7cffd5915608d988">VectorInit</a> (<a class="el" href="structVector.html">Vector</a> **ppObj, int32_t iCap)</td></tr>
<tr class="memdesc:aee13af756ae9331b7cffd5915608d988"><td class="mdescLeft">&#160;</td><td class="mdescRight">The constructor for <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a>.  <a href="#aee13af756ae9331b7cffd5915608d988">More...</a><br/></td></tr>
<tr class="separator:aee13af756ae9331b7cffd5915608d988"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a55d4d7d2f5dfee1f7b25fd7c92d22f27"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a55d4d7d2f5dfee1f7b25fd7c92d22f27">VectorDeinit</a> (<a class="el" href="structVector.html">Vector</a> **ppObj)</td></tr>
<tr class="memdesc:a55d4d7d2f5dfee1f7b25fd7c92d22f27"><td class="mdescLeft">&#160;</td><td class="mdescRight">The destructor for <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a>.  <a href="#a55d4d7d2f5dfee1f7b25fd7c92d22f27">More...</a><br/></td></tr>
<tr class="separator:a55d4d7d2f5dfee1f7b25fd7c92d22f27"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7c4fa1c894e411db9c05639c3062a985"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a7c4fa1c894e411db9c05639c3062a985">VectorPushBack</a> (<a class="el" href="structVector.html">Vector</a> *self, Item item)</td></tr>
<tr class="memdesc:a7c4fa1c894e411db9c05639c3062a985"><td class="mdescLeft">&#160;</td><td class="mdescRight">Push an item to the tail of the vector.  <a href="#a7c4fa1c894e411db9c05639c3062a985">More...</a><br/></td></tr>
<tr class="separator:a7c4fa1c894e411db9c05639c3062a985"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a67e0f39d32d550ce592ace927d496c3b"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a67e0f39d32d550ce592ace927d496c3b">VectorInsert</a> (<a class="el" href="structVector.html">Vector</a> *self, Item item, int32_t iIdx)</td></tr>
<tr class="memdesc:a67e0f39d32d550ce592ace927d496c3b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Insert an item to the designated index of the vector.  <a href="#a67e0f39d32d550ce592ace927d496c3b">More...</a><br/></td></tr>
<tr class="separator:a67e0f39d32d550ce592ace927d496c3b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a99ccfafe2c7578449c30ac36ee5ea85b"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a99ccfafe2c7578449c30ac36ee5ea85b">VectorPopBack</a> (<a class="el" href="structVector.html">Vector</a> *self)</td></tr>
<tr class="memdesc:a99ccfafe2c7578449c30ac36ee5ea85b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pop an item from the tail of the vector.  <a href="#a99ccfafe2c7578449c30ac36ee5ea85b">More...</a><br/></td></tr>
<tr class="separator:a99ccfafe2c7578449c30ac36ee5ea85b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8e3f2e20699db4db95b6b3eea78699f9"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a8e3f2e20699db4db95b6b3eea78699f9">VectorDelete</a> (<a class="el" href="structVector.html">Vector</a> *self, int32_t iIdx)</td></tr>
<tr class="memdesc:a8e3f2e20699db4db95b6b3eea78699f9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete an item from the designated index of the vector.  <a href="#a8e3f2e20699db4db95b6b3eea78699f9">More...</a><br/></td></tr>
<tr class="separator:a8e3f2e20699db4db95b6b3eea78699f9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a04e4098bc20098fba01e057db43549a3"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a04e4098bc20098fba01e057db43549a3">VectorSet</a> (<a class="el" href="structVector.html">Vector</a> *self, Item item, int32_t iIdx)</td></tr>
<tr class="memdesc:a04e4098bc20098fba01e057db43549a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set an item at the designated index of the vector.  <a href="#a04e4098bc20098fba01e057db43549a3">More...</a><br/></td></tr>
<tr class="separator:a04e4098bc20098fba01e057db43549a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad69c5de92277cdb34fd3a5476ef18e08"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#ad69c5de92277cdb34fd3a5476ef18e08">VectorGet</a> (<a class="el" href="structVector.html">Vector</a> *self, Item *pItem, int32_t iIdx)</td></tr>
<tr class="memdesc:ad69c5de92277cdb34fd3a5476ef18e08"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get an item from the designated index of the vector.  <a href="#ad69c5de92277cdb34fd3a5476ef18e08">More...</a><br/></td></tr>
<tr class="separator:ad69c5de92277cdb34fd3a5476ef18e08"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6f8dc6d9ab0a790c66acec7340dcd118"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a6f8dc6d9ab0a790c66acec7340dcd118">VectorResize</a> (<a class="el" href="structVector.html">Vector</a> *self, int32_t iCap)</td></tr>
<tr class="memdesc:a6f8dc6d9ab0a790c66acec7340dcd118"><td class="mdescLeft">&#160;</td><td class="mdescRight">Change the container capacity.  <a href="#a6f8dc6d9ab0a790c66acec7340dcd118">More...</a><br/></td></tr>
<tr class="separator:a6f8dc6d9ab0a790c66acec7340dcd118"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3d6adfa3c82db3a3d14d96ae5aa0f941"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a3d6adfa3c82db3a3d14d96ae5aa0f941">VectorSize</a> (<a class="el" href="structVector.html">Vector</a> *self)</td></tr>
<tr class="memdesc:a3d6adfa3c82db3a3d14d96ae5aa0f941"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the number of stored items.  <a href="#a3d6adfa3c82db3a3d14d96ae5aa0f941">More...</a><br/></td></tr>
<tr class="separator:a3d6adfa3c82db3a3d14d96ae5aa0f941"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aebe9767f9216efa7efcd5d006ea47009"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#aebe9767f9216efa7efcd5d006ea47009">VectorCapacity</a> (<a class="el" href="structVector.html">Vector</a> *self)</td></tr>
<tr class="memdesc:aebe9767f9216efa7efcd5d006ea47009"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the container capacity.  <a href="#aebe9767f9216efa7efcd5d006ea47009">More...</a><br/></td></tr>
<tr class="separator:aebe9767f9216efa7efcd5d006ea47009"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa3a8d94d6fffaf20d61dd713d2bf84fd"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#aa3a8d94d6fffaf20d61dd713d2bf84fd">VectorSort</a> (<a class="el" href="structVector.html">Vector</a> *self, int32_t(*pFunc)(const void *, const void *))</td></tr>
<tr class="memdesc:aa3a8d94d6fffaf20d61dd713d2bf84fd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sort the items via the designated item comparison method.  <a href="#aa3a8d94d6fffaf20d61dd713d2bf84fd">More...</a><br/></td></tr>
<tr class="separator:aa3a8d94d6fffaf20d61dd713d2bf84fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3f8bbcf02e7f5e6bd975aa87a0f0ea21"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a3f8bbcf02e7f5e6bd975aa87a0f0ea21">VectorIterate</a> (<a class="el" href="structVector.html">Vector</a> *self, bool bReset, Item *pItem)</td></tr>
<tr class="memdesc:a3f8bbcf02e7f5e6bd975aa87a0f0ea21"><td class="mdescLeft">&#160;</td><td class="mdescRight">Iterate through the vector till the tail end.  <a href="#a3f8bbcf02e7f5e6bd975aa87a0f0ea21">More...</a><br/></td></tr>
<tr class="separator:a3f8bbcf02e7f5e6bd975aa87a0f0ea21"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a010ad24d57d84416859b3f2bc928056c"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a010ad24d57d84416859b3f2bc928056c">VectorReverseIterate</a> (<a class="el" href="structVector.html">Vector</a> *self, bool bReset, Item *pItem)</td></tr>
<tr class="memdesc:a010ad24d57d84416859b3f2bc928056c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reversely iterate through the vector till the head end.  <a href="#a010ad24d57d84416859b3f2bc928056c">More...</a><br/></td></tr>
<tr class="separator:a010ad24d57d84416859b3f2bc928056c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6ae446f90b85e646fa3dd6e515afe0f9"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vector_8h.html#a6ae446f90b85e646fa3dd6e515afe0f9">VectorSetDestroy</a> (<a class="el" href="structVector.html">Vector</a> *self, void(*pFunc)(Item))</td></tr>
<tr class="memdesc:a6ae446f90b85e646fa3dd6e515afe0f9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the custom item resource clean method.  <a href="#a6ae446f90b85e646fa3dd6e515afe0f9">More...</a><br/></td></tr>
<tr class="separator:a6ae446f90b85e646fa3dd6e515afe0f9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The dynamically growable array. </p>

<p>Definition in file <a class="el" href="vector_8h_source.html">vector.h</a>.</p>
</div><h2 class="groupheader">Typedef Documentation</h2>
<a class="anchor" id="ae7e1bc0ebd3e2d9616179a88c660aafe"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct _VectorData <a class="el" href="vector_8h.html#ae7e1bc0ebd3e2d9616179a88c660aafe">VectorData</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>VectorData is the data type for the container private information. </p>

<p>Definition at line <a class="el" href="vector_8h_source.html#l00011">11</a> of file <a class="el" href="vector_8h_source.html">vector.h</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="aee13af756ae9331b7cffd5915608d988"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorInit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> **&#160;</td>
          <td class="paramname"><em>ppObj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>iCap</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The constructor for <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a>. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ppObj</td><td>The double pointer to the to be constructed vector </td></tr>
    <tr><td class="paramname">iCap</td><td>The designated initial capacity</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOMEM</td><td>Insufficient memory for vector construction</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>Specify iCap to 0 for default initial capacity. </dd></dl>

</div>
</div>
<a class="anchor" id="a55d4d7d2f5dfee1f7b25fd7c92d22f27"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void VectorDeinit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> **&#160;</td>
          <td class="paramname"><em>ppObj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The destructor for <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a>. </p>
<p>If the custom resource clean method is set, it also runs the clean method for all the items.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ppObj</td><td>The double pointer to the to be destructed vector </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a7c4fa1c894e411db9c05639c3062a985"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorPushBack </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item&#160;</td>
          <td class="paramname"><em>item</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Push an item to the tail of the vector. </p>
<p>This function pushes an item to the tail of the vector with the corresponding vector size extension. If the storage is full, the space reallocation is automatically triggered to store the newly pushed item.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">item</td><td>The designated item</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_NOMEM</td><td>Insufficient memory for vector extension </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a67e0f39d32d550ce592ace927d496c3b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorInsert </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item&#160;</td>
          <td class="paramname"><em>item</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>iIdx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Insert an item to the designated index of the vector. </p>
<p>This function inserts an item to the designated index of the vector and shifts the trailing items one position to the tail. Naturally, the vector size is extended. And if the storage is full, the space reallocation is automatically triggered to store the newly inserted item.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">item</td><td>The designated item </td></tr>
    <tr><td class="paramname">iIdx</td><td>The designated index</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_IDX</td><td>Illegal index</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>The designated index should be equal to or smaller than the vector size and should not be negative. If the index is equal to the vector size, the effect is equivalent to push_back(). </dd></dl>

</div>
</div>
<a class="anchor" id="a99ccfafe2c7578449c30ac36ee5ea85b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorPopBack </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Pop an item from the tail of the vector. </p>
<p>This function removes an item from the tail of the vector. If the custom resource clean method is set, it also runs the clean method for the removed item. Naturally, the vector size is shrunk.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_IDX</td><td>Empty vector </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a8e3f2e20699db4db95b6b3eea78699f9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorDelete </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>iIdx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Delete an item from the designated index of the vector. </p>
<p>This function removes an item from the designated index of the vector and shifts the trailing items one position to the head. If the custom resource clean method is set, it also runs the clean method for the removed item. Naturally, the vector size is shrunk.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">iIdx</td><td>The designated index</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_IDX</td><td>Illegal index</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>The designated index should be smaller than the vector size and should not be negative. If the index is equal to the vector size minus one, the operation is equivalent to pop_back(). </dd></dl>

</div>
</div>
<a class="anchor" id="a04e4098bc20098fba01e057db43549a3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorSet </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item&#160;</td>
          <td class="paramname"><em>item</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>iIdx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set an item at the designated index of the vector. </p>
<p>This function replaces an item at the designated index of the vector. If the custom resource clean method is set, it also runs the clean method for the replaced item.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">item</td><td>The designated item </td></tr>
    <tr><td class="paramname">iIdx</td><td>The designated index</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_IDX</td><td>Illegal index</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>The designated index should be smaller than the vector size and should not be negative. </dd></dl>

</div>
</div>
<a class="anchor" id="ad69c5de92277cdb34fd3a5476ef18e08"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorGet </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item *&#160;</td>
          <td class="paramname"><em>pItem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>iIdx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get an item from the designated index of the vector. </p>
<p>This function retrieves an item from the designated index of the vector. If the index is illegal, the error code is returned and the second parameter is also updated with NULL.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">pItem</td><td>The pointer to the returned item </td></tr>
    <tr><td class="paramname">iIdx</td><td>The designated index</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_IDX</td><td>Illegal index </td></tr>
    <tr><td class="paramname">ERR_GET</td><td>Invalid parameter to store returned item</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>The designated index should be smaller than the vector size and should not be negative. </dd></dl>

</div>
</div>
<a class="anchor" id="a6f8dc6d9ab0a790c66acec7340dcd118"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorResize </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>iCap</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Change the container capacity. </p>
<p>This function resizes the storage capacity. If the new capacity is smaller than the old size. The trailing items will be removed. If the custom resource clean method is set, it also runs the clean method for the removed items.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">iCap</td><td>The designated capacity</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_NOMEM</td><td>Insufficient memory for vector extension</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>The designated capacity should greater than zero. </dd></dl>

</div>
</div>
<a class="anchor" id="a3d6adfa3c82db3a3d14d96ae5aa0f941"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorSize </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Return the number of stored items. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of stored items </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aebe9767f9216efa7efcd5d006ea47009"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorCapacity </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Return the container capacity. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The container capacity </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aa3a8d94d6fffaf20d61dd713d2bf84fd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorSort </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t(*)(const void *, const void *)&#160;</td>
          <td class="paramname"><em>pFunc</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sort the items via the designated item comparison method. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">pFunc</td><td>The function pointer to the custom method</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a3f8bbcf02e7f5e6bd975aa87a0f0ea21"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorIterate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>bReset</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item *&#160;</td>
          <td class="paramname"><em>pItem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Iterate through the vector till the tail end. </p>
<p>Before iterating through the vector, it is necessary to pass bReset := true and pItem := NULL for iterator initialization. After initialization, you can pass bReset := false and pItem := the relevant pointer to get the returned item at each iteration.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">bReset</td><td>The knob to reset the iteration </td></tr>
    <tr><td class="paramname">pItem</td><td>The pointer to the returned item</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">END</td><td>At the tail end of the vector </td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_GET</td><td>Invalid parameter to store returned item </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a010ad24d57d84416859b3f2bc928056c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorReverseIterate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>bReset</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item *&#160;</td>
          <td class="paramname"><em>pItem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reversely iterate through the vector till the head end. </p>
<p>Before reversely iterating through the vector, it is necessary to pass bReset := true and pItem := NULL for iterator initialization. After initialization, you can pass bReset := false and pItem := the relevant pointer to get the returned item at each iteration.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">bReset</td><td>The knob to reset the iteration </td></tr>
    <tr><td class="paramname">pItem</td><td>The pointer to the returned item</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">END</td><td>At the tail end of the vector </td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_GET</td><td>Invalid parameter to store returned item </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a6ae446f90b85e646fa3dd6e515afe0f9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t VectorSetDestroy </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void(*)(Item)&#160;</td>
          <td class="paramname"><em>pFunc</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set the custom item resource clean method. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to the <a class="el" href="structVector.html" title="The implementation for dynamically growable array. ">Vector</a> structure </td></tr>
    <tr><td class="paramname">pFunc</td><td>The function pointer to the custom method</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_e0f5f6345e438c73b9ae78ec2940718c.html">container</a></li><li class="navelem"><a class="el" href="vector_8h.html">vector.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
